<template>
  <div class="main">
    <div class="search">
      <el-form :inline="true" :model="search">
        <el-form-item>
          <el-button type="success" size="small" @click="form = { adStatus: true }; dialogShow = true">添加</el-button>
        </el-form-item>
        <el-form-item label="产品型号名称">
          <el-input v-model="search.prApplicationName" size="small" placeholder="产品型号名称" clearable></el-input>
        </el-form-item>
        <el-form-item label="生产者">
          <el-input v-model="search.prProducer" size="small" placeholder="生产者" clearable></el-input>
        </el-form-item>
        <el-form-item label="生产厂">
          <el-input v-model="search.prManufacturingPlant" size="small" placeholder="生产厂" clearable></el-input>
        </el-form-item>
        <!--        <el-form-item label="备注">-->
        <!--          <el-input v-model="search.description" size="small" placeholder="备注" clearable></el-input>-->
        <!--        </el-form-item>-->
        <el-form-item>
          <el-button type="info" size="small" @click="searchClick">查询</el-button>
        </el-form-item>
      </el-form>
    </div>
    <div class="list">
      <el-table
          :data="data"
          stripe
          style="width: 100%">
        <el-table-column prop="prApplicationName" label="产品型号名称"></el-table-column>
        <el-table-column prop="prProducer" label="生产者"></el-table-column>
        <el-table-column prop="prManufacturingPlant" label="生产厂"></el-table-column>
        <el-table-column prop="prIdentificationClass" label="鉴定类别"></el-table-column>
        <el-table-column prop="prCreated" label="创建时间"></el-table-column>
        <el-table-column label="操作" width="500px">
          <template slot-scope="scope">
            <el-button type="primary" @click="form = {...scope.row}; dialogShow = true">编辑</el-button>
            <el-button type="success"
                       @click="editReportForm(scope.row.prId); form = {...scope.row}; reportDialogShow = true">编辑检验报告
            </el-button>
            <el-button type="info"
                       @click="editProductInfoForm(scope.row.prId); form = {...scope.row}; productInfoDialogShow = true">
              编辑推广鉴定报告
            </el-button>
            <el-button type="danger" @click="del(scope.row.prId)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
          @size-change="sizeChange"
          @current-change="currentChange"
          :current-page="pageNo"
          :page-sizes="[10, 20, 50, 100]"
          :page-size="pageSize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total">
      </el-pagination>
    </div>
    <el-dialog
        :title="form.id ? '修改' : '添加'"
        :visible.sync="dialogShow"
        width="600px"
        @close="dialogClose"
    >
      <el-form ref="form" :model="form" label-width="100px" :rules="rules">
        <el-form-item prop="adName" label="产品型号名称">
          <el-input type="text" placeholder="请输入产品型号名称" v-model="form.prApplicationName"/>
        </el-form-item>
        <el-form-item prop="adUserName" label="生产者">
          <el-input type="text" placeholder="请输入用户名" v-model="form.prProducer"/>
        </el-form-item>
        <el-form-item prop="adPassWord" label="生产厂">
          <el-input type="text" placeholder="请输入生产厂" v-model="form.prManufacturingPlant"/>
        </el-form-item>
<!--        <el-form-item prop="adPhone" label="鉴定类别">-->
<!--          <el-input type="text" placeholder="请输入鉴定类别" v-model="form.prIdentificationClass"/>-->
<!--        </el-form-item>-->
        <el-form-item>
          <el-button type="primary" @click="submit">保存</el-button>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogShow = false">关闭</el-button>
      </span>
    </el-dialog>
    <el-dialog
        :title="reportForm.id ? '修改' : '添加'"
        :visible.sync="reportDialogShow"
        width="600px"
        fullscreen
        @close="dialogClose"
    >
      <el-form ref="form" :model="reportForm" label-width="100px" :rules="rules">
        <el-row>
          <el-col :span="8">
            <el-form-item prop="productName" label="样品名称">
              <el-input type="text" placeholder="请输入样品名称" v-model="reportForm.productName"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="sampleType" label="样品型号">
              <el-input type="text" placeholder="请输入样品型号" v-model="reportForm.sampleType"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="sampleNum" label="样品数量">
              <el-input type="text" placeholder="请输入样品数量" v-model="reportForm.sampleNum"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="sampleBernum" label="样品编号">
              <el-input type="text" placeholder="请输入样品编号" v-model="reportForm.sampleBernum"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="producerName" label="生产者名称">
              <el-input type="text" placeholder="请输入用户名" v-model="reportForm.producerName"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="registeredAddress" label="注册地址">
              <el-input type="text" placeholder="请输入注册地址" v-model="reportForm.registeredAddress"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="manufactoryName" label="生产厂名称">
              <el-input type="text" placeholder="请输入生产厂名称" v-model="reportForm.manufactoryName"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="registeredAddressSample" label="样品注册地址">
              <el-input type="text" placeholder="请输入样品注册地址" v-model="reportForm.registeredAddressSample"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="productionDate" label="样品生产日期">
              <el-date-picker
                  v-model="reportForm.productionDate"
                  type="date"
                  format="yyyy-MM-dd"
                  placeholder="选择样品生产日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="sampleAcqMethod" label="样品取得方式">
              <el-input type="text" placeholder="请输入样品取得方式" v-model="reportForm.sampleAcqMethod"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="samplingBasicDate" label="抽/供样日期">
              <el-date-picker
                  v-model="reportForm.samplingBasicDate"
                  type="date"
                  format="yyyy-MM-dd"
                  placeholder="选择样品抽/供样日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="arriveDate" label="到样时间">
              <el-date-picker
                  v-model="reportForm.arriveDate"
                  type="date"
                  format="yyyy-MM-dd"
                  placeholder="选择到样时间">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="sampleGrade" label="样品等级">
              <el-input type="text" placeholder="请输入样品等级" v-model="reportForm.sampleGrade"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="samplingBasicNumber" label="抽样基数">
              <el-input type="text" placeholder="请输入抽样基数" v-model="reportForm.samplingBasicNumber"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="samplingBasicPlace" label="抽/验样地点">
              <el-input type="text" placeholder="请输入抽/验样地点" v-model="reportForm.samplingBasicPlace"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="provingTime" label="检验时间">
              <el-date-picker
                  v-model="reportForm.provingTime"
                  type="date"
                  format="yyyy-MM-dd"
                  placeholder="选择检验时间">
              </el-date-picker>
            </el-form-item>
          </el-col>

          <el-col :span="8">
            <el-form-item prop="checkGroundPoint" label="检验地点">
              <el-input type="text" placeholder="请输入检验地点" v-model="reportForm.checkGroundPoint"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="mainTestingEquipment" label="检验依据">
              <el-input type="text" placeholder="请输入检验依据" v-model="reportForm.mainTestingEquipment"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="checkConclusion" label="检验结论">
              <el-input type="text" placeholder="请输入检验结论" v-model="reportForm.checkConclusion"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="remark" label="检验备注">
              <el-input type="text" placeholder="请输入备注" v-model="reportForm.remark"/>
            </el-form-item>
          </el-col>
        </el-row>
        <br/>
        <el-row>
          <el-col :span="12">
            <el-form-item prop="pictureProductName" label="样品照片">
              <el-upload
                  class="avatar-uploader"
                  :style="{border: !reportForm.pictureProductName ? '1px solid #d9d9d9' : ''}"
                  style="max-width: 160px; max-height: 160px"
                  :action="baseUrl + '/reportApproval/report/fileUplod'"
                  :headers="{'Authorization': getToken()}"
                  :show-file-list="false"
                  :on-success="(response, file, fileList) => {
                    return handleAvatarSuccess(response, file, fileList, reportForm, 'pictureProductName')
                  }"
                  :before-upload="beforeAvatarUpload">
                <img v-if="reportForm.pictureProductName" :src="reportForm.pictureProductName"
                     style="height: 160px; max-width: 260px;" class="avatar">
                <i v-else class="el-icon-plus avatar-uploader-icon" style="margin-left: 40px; margin-top: 40px;"></i>
              </el-upload>
              <!--              <el-input type="text" placeholder="请输入样品照片" v-model="reportForm.pictureProductName"/>-->
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item prop="涵盖机型" label="样品图片">
              <el-upload
                  class="avatar-uploader"
                  :style="{border: !reportForm.pictureModel ? '1px solid #d9d9d9' : ''}"
                  style="max-width: 160px; max-height: 160px"
                  :action="baseUrl + '/reportApproval/report/fileUplod'"
                  :headers="{'Authorization': getToken()}"
                  :show-file-list="false"
                  :on-success="(response, file, fileList) => {
                    return handleAvatarSuccess(response, file, fileList, reportForm, 'pictureModel')
                  }"
                  :before-upload="beforeAvatarUpload">
                <img v-if="reportForm.pictureModel" :src="reportForm.pictureModel"
                     style="height: 160px; max-width: 260px;" class="avatar">
                <i v-else class="el-icon-plus avatar-uploader-icon" style="margin-left: 40px; margin-top: 40px;"></i>
              </el-upload>
            </el-form-item>
          </el-col>
        </el-row>

        <br/>
        <el-row>
          <el-col :span="1">
            <el-button type="primary" circle icon="el-icon-plus"
                       @click="addItem(reportForm.reportConditionVo)"></el-button>
          </el-col>
          <el-col :span="23">
            <span style="margin-left: 30px; font-weight: bold; font-size: 20px;">
              试验条件
            </span>
            <span style="margin-left: 30px">
              备注：描述影响检验结果的主要条件。
            </span>
          </el-col>
        </el-row>
        <el-row v-for="(item, index) in reportForm.reportConditionVo" :key="index">
          <el-col :span="4">
            <el-form-item label="序号">
              {{ index + 1 }}
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item prop="projectName" label="项目">
              <el-input type="text" placeholder="请输入项目" v-model="item.projectName"/>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item prop="unit" label="单位">
              <el-input type="text" placeholder="请输入单位" v-model="item.unit"/>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item prop="measuredResult" label="测定结果">
              <el-input type="text" placeholder="请输入测定结果" v-model="item.measuredResult"/>
            </el-form-item>
          </el-col>
          <el-col :offset="10" :span="4">
            <el-form-item>
              <!--              <el-button type="primary" v-if="reportForm.reportConditionVo.length === index + 1" circle icon="el-icon-plus" @click="addItem(reportForm.reportConditionVo)"></el-button>-->
              <el-button v-if="index > 0" type="danger" circle icon="el-icon-minus"
                         @click="delItem(reportForm.reportConditionVo, index)"></el-button>
            </el-form-item>
          </el-col>
        </el-row>
        <br/>
        <el-row>
          <el-col :span="2">
            <el-button type="primary" circle icon="el-icon-plus"
                       @click="addItem(reportForm.reportCheckResultVo)"></el-button>
          </el-col>
          <el-col :span="22">
            <span style="margin-left: 30px; font-weight: bold; font-size: 20px;">
              样品一致性检查结果
            </span>
            <div style="margin-left: 30px">
              <br/>（1）单项判断合格填“+”，不合格填“-”。<br/>
              （2）大纲中对样品不适用的检查项目，应在表中列出，在检查结果、单项判断栏中填“/”，并在备注中说明。
            </div>
          </el-col>
        </el-row>
        <el-row v-for="(item, index) in reportForm.reportCheckResultVo" :key="index">
          <el-col :span="4">
            <el-form-item label="序号">
              {{ index + 1 }}
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item prop="projectName" label="项目">
              <el-input type="text" placeholder="请输入项目" v-model="item.projectName"/>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item prop="unit" label="单位">
              <el-input type="text" placeholder="请输入单位" v-model="item.unit"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="designValue" label="设计值">
              <el-input type="text" placeholder="请输入设计值" v-model="item.designValue"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="limitedField" label="限制范围">
              <el-input type="text" placeholder="请输入限制范围" v-model="item.limitedField"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="checkResult" label="检查结果">
              <el-input type="text" placeholder="请输入检查结果" v-model="item.checkResult"/>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item prop="unitaryDetermine" label="单项判定">
              <el-input type="text" placeholder="请输入单项判定" v-model="item.unitaryDetermine"/>
            </el-form-item>
          </el-col>
          <el-col :offset="10" :span="4">
            <el-form-item>
              <!--              <el-button type="primary" v-if="reportForm.reportCheckResultVo.length === index + 1" circle icon="el-icon-plus" @click="addItem(reportForm.reportCheckResultVo)"></el-button>-->
              <el-button v-if="index > 0" type="danger" circle icon="el-icon-minus"
                         @click="delItem(reportForm.reportCheckResultVo, index)"></el-button>
            </el-form-item>
          </el-col>
        </el-row>
        <br/>
        <el-row>
          <el-col :span="1">
            <el-button type="primary" circle icon="el-icon-plus"
                       @click="addItem(reportForm.reportSampleSonsResultsVo)"></el-button>
          </el-col>
          <el-col :span="23">
            <span style="margin-left: 30px; font-weight: bold; font-size: 20px;">
              涵盖机型（或同单元机型）样品一致性检查结果
            </span>
            <div style="margin-left: 30px">
              <br/>（1）单项判断合格填“+”，不合格填“-”。<br/>
              （2）大纲中对样品不适用的检查项目，应在表中列出，在检查结果、单项判断栏中填“/”，并在备注中说明。<br/>
              （3）描述未经确认的涵盖机型（或同单元机型）技术规格设计值获取方式。
            </div>
          </el-col>
        </el-row>
        <el-row v-for="(item, index) in reportForm.reportSampleSonsResultsVo" :key="index">
          <el-col :span="4">
            <el-form-item label="序号">
              {{ index + 1 }}
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item prop="projectName" label="项目">
              <el-input type="text" placeholder="请输入项目" v-model="item.projectName"/>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item prop="unit" label="单位">
              <el-input type="text" placeholder="请输入单位" v-model="item.unit"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="designValue" label="设计值">
              <el-input type="text" placeholder="请输入设计值" v-model="item.designValue"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="limitedField" label="限制范围">
              <el-input type="text" placeholder="请输入限制范围" v-model="item.limitedField"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="checkResult" label="检查结果">
              <el-input type="text" placeholder="请输入检查结果" v-model="item.checkResult"/>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item prop="unitaryDetermine" label="单项判定">
              <el-input type="text" placeholder="请输入单项判定" v-model="item.unitaryDetermine"/>
            </el-form-item>
          </el-col>
          <el-col :offset="10" :span="4">
            <el-form-item>
              <!--              <el-button type="primary" v-if="reportForm.reportSampleSonsResultsVo.length === index + 1" circle icon="el-icon-plus" @click="addItem(reportForm.reportSampleSonsResultsVo)"></el-button>-->
              <el-button v-if="index > 0" type="danger" circle icon="el-icon-minus"
                         @click="delItem(reportForm.reportSampleSonsResultsVo, index)"></el-button>
            </el-form-item>
          </el-col>
        </el-row>
        <br/>
        <el-row>
          <el-col :span="1">
            <el-button type="primary" circle icon="el-icon-plus"
                       @click="addItem(reportForm.reportSampleSafetyResultsVo)"></el-button>
          </el-col>
          <el-col :span="23">
            <span style="margin-left: 30px; font-weight: bold; font-size: 20px;">
              样品安全性检验结果
            </span>
            <div style="margin-left: 30px">
              <br/>
              （1）单项判定合格填“+”，不合格填“-”。<br/>
              （2）大纲中对样品不适用的检查项目，应在表中列出，在检查结果、单项判定栏中填“/”，并在备注中说明；<br/>
              （3）采信具有资质的检验检测机构出具的报告，不应体现采信项目的数据结果，可在采信项目的“检验结果”“单项判定”栏中划“/”，并在备注中注明采信项目的来源，如：采信报告的编号、名称及检验检测机构名称等。
            </div>
          </el-col>
        </el-row>
        <el-row v-for="(item, index) in reportForm.reportSampleSafetyResultsVo" :key="index">
          <el-col :span="4">
            <el-form-item label="序号">
              {{ index + 1 }}
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item prop="projectName" label="项目">
              <el-input type="text" placeholder="请输入项目" v-model="item.projectName"/>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item prop="unit" label="单位">
              <el-input type="text" placeholder="请输入单位" v-model="item.unit"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="qualifiedIndicator" label="合格指标">
              <el-input type="text" placeholder="请输入合格指标" v-model="item.qualifiedIndicator"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="checkResult" label="检验结果">
              <el-input type="text" placeholder="请输入检查结果" v-model="item.checkResult"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="unitaryDetermine" label="单项判定">
              <el-input type="text" placeholder="请输入单项判定" v-model="item.unitaryDetermine"/>
            </el-form-item>
          </el-col>
          <el-col :offset="20" :span="4">
            <el-form-item>
              <!--              <el-button type="primary" v-if="reportForm.reportSampleSafetyResultsVo.length === index + 1" circle icon="el-icon-plus" @click="addItem(reportForm.reportSampleSafetyResultsVo)"></el-button>-->
              <el-button v-if="index > 0" type="danger" circle icon="el-icon-minus"
                         @click="delItem(reportForm.reportSampleSafetyResultsVo, index)"></el-button>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="1">
            <el-button type="primary" circle icon="el-icon-plus"
                       @click="addItem(reportForm.reportConsResultsVo)"></el-button>
          </el-col>
          <el-col :span="23">
            <span style="margin-left: 30px; font-weight: bold; font-size: 20px;">
              涵盖机型（或同单元机型）样品安全性检验结果（若有）
            </span>
            <div style="margin-left: 30px">
              <br/>
              （1）单项判定合格填“+”，不合格填“-”。<br/>
              （2）大纲中对样品不适用的检查项目，应在表中列出，在检验结果、单项判定栏中填“/”，并在备注中说明。<br/>
              （3）采信具有资质的检验检测机构出具的报告，不应体现采信项目的数据结果，可在采信项目的“检验结果”“单项判定”栏中划“/”，并在备注中注明采信项目的来源，如：采信报告的编号、名称及检验检测机构名称等。
            </div>
          </el-col>
        </el-row>
        <el-row v-for="(item, index) in reportForm.reportConsResultsVo" :key="index">
          <el-col :span="4">
            <el-form-item label="序号">
              {{ index + 1 }}
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item prop="projectName" label="项目">
              <el-input type="text" placeholder="请输入项目" v-model="item.projectName"/>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item prop="unit" label="单位">
              <el-input type="text" placeholder="请输入单位" v-model="item.unit"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="qualifiedIndicator" label="合格指标">
              <el-input type="text" placeholder="请输入合格指标" v-model="item.qualifiedIndicator"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="checkResult" label="检验结果">
              <el-input type="text" placeholder="请输入检查结果" v-model="item.checkResult"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="unitaryDetermine" label="单项判定">
              <el-input type="text" placeholder="请输入单项判定" v-model="item.unitaryDetermine"/>
            </el-form-item>
          </el-col>
          <el-col :offset="20" :span="4">
            <el-form-item>
              <!--              <el-button type="primary" v-if="reportForm.reportConsResultsVo.length === index + 1" circle icon="el-icon-plus" @click="addItem(reportForm.reportConsResultsVo)"></el-button>-->
              <el-button type="danger" circle icon="el-icon-minus"
                         @click="delItem(reportForm.reportConsResultsVo, index)"></el-button>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="1">
            <el-button type="primary" circle icon="el-icon-plus"
                       @click="addItem(reportForm.reportSampleSuitResultsVo)"></el-button>
          </el-col>
          <el-col :span="23">
            <span style="margin-left: 30px; font-weight: bold; font-size: 20px;">
              样品适用性检验结果
            </span>
            <div style="margin-left: 30px">
              <br/>
              （1）单项判定合格填“+”，不合格填“-”。<br/>
              （2）大纲中对样品不适用的检查项目，应在表中列出，在检验结果、单项判定栏中填“/”，并在备注中说明。<br/>
              （3）采信具有资质的检验检测机构出具的报告，不应体现采信项目的数据结果，可在采信项目的“检验结果”“单项判定”栏中划“/”，并在备注中注明采信项目的来源，如：采信报告的编号、名称及检验检测机构名称等。
            </div>
          </el-col>
        </el-row>
        <el-row v-for="(item, index) in reportForm.reportSampleSuitResultsVo" :key="index">
          <el-col :span="4">
            <el-form-item label="序号">
              {{ index + 1 }}
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item prop="projectName" label="项目">
              <el-input type="text" placeholder="请输入项目" v-model="item.projectName"/>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item prop="unit" label="单位">
              <el-input type="text" placeholder="请输入单位" v-model="item.unit"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="qualifiedIndicator" label="合格指标">
              <el-input type="text" placeholder="请输入合格指标" v-model="item.qualifiedIndicator"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="checkResult" label="检验结果">
              <el-input type="text" placeholder="请输入检查结果" v-model="item.checkResult"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="unitaryDetermine" label="单项判定">
              <el-input type="text" placeholder="请输入单项判定" v-model="item.unitaryDetermine"/>
            </el-form-item>
          </el-col>
          <el-col :offset="20" :span="4">
            <el-form-item>
              <!--              <el-button type="primary" v-if="reportForm.reportSampleSuitResultsVo.length === index + 1" circle icon="el-icon-plus" @click="addItem(reportForm.reportSampleSuitResultsVo)"></el-button>-->
              <el-button v-if="index > 0" type="danger" circle icon="el-icon-minus"
                         @click="delItem(reportForm.reportSampleSuitResultsVo, index)"></el-button>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="1">
            <el-button type="primary" circle icon="el-icon-plus"
                       @click="addItem(reportForm.reportSampleSuitResultsVo)"></el-button>
          </el-col>
          <el-col :span="23">
            <span style="margin-left: 30px; font-weight: bold; font-size: 20px;">
              涵盖机型（或同单元机型）样品适用性检验结果（若有）
            </span>
            <div style="margin-left: 30px">
              <br/>
              （1）单项判定合格填“+”，不合格填“-”。<br/>
              （2）大纲中对样品不适用的检查项目，应在表中列出，在检验结果、单项判定栏中填“/”，并在备注中说明。<br/>
              （3）采信具有资质的检验检测机构出具的报告，不应体现采信项目的数据结果，可在采信项目的“检验结果”“单项判定”栏中划“/”，并在备注中注明采信项目的来源，如：采信报告的编号、名称及检验检测机构名称等。
            </div>
          </el-col>
        </el-row>
        <el-row v-for="(item, index) in reportForm.reportSampleSuitResultsVo" :key="index">
          <el-col :span="4">
            <el-form-item label="序号">
              {{ index + 1 }}
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item prop="projectName" label="项目">
              <el-input type="text" placeholder="请输入项目" v-model="item.projectName"/>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item prop="unit" label="单位">
              <el-input type="text" placeholder="请输入单位" v-model="item.unit"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="qualifiedIndicator" label="合格指标">
              <el-input type="text" placeholder="请输入合格指标" v-model="item.qualifiedIndicator"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="checkResult" label="检验结果">
              <el-input type="text" placeholder="请输入检查结果" v-model="item.checkResult"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="unitaryDetermine" label="单项判定">
              <el-input type="text" placeholder="请输入单项判定" v-model="item.unitaryDetermine"/>
            </el-form-item>
          </el-col>
          <el-col :offset="20" :span="4">
            <el-form-item>
              <!--              <el-button type="primary" v-if="reportForm.reportSampleSuitResultsVo.length === index + 1" circle icon="el-icon-plus" @click="addItem(reportForm.reportSampleSuitResultsVo)"></el-button>-->
              <el-button type="danger" circle icon="el-icon-minus"
                         @click="delItem(reportForm.reportSampleSuitResultsVo, index)"></el-button>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="1">
            <el-button type="primary" circle icon="el-icon-plus"
                       @click="addItem(reportForm.reportReliabilityResultVo)"></el-button>
          </el-col>
          <el-col :span="23">
            <span style="margin-left: 30px; font-weight: bold; font-size: 20px;">
              样品可靠性检验结果
            </span>
            <div style="margin-left: 30px">
              <br/>
              （1）单项判定合格填“+”，不合格填“-”。<br/>
              （2）大纲中对样品不适用的检查项目，应在表中列出，在检验结果、单项判定栏中填“/”，并在备注中说明。<br/>
              （3）采信具有资质的检验检测机构出具的报告，不应体现采信项目的数据结果，可在采信项目的“检验结果”“单项判定”栏中划“/”，并在备注中注明采信项目的来源，如：采信报告的编号、名称及检验检测机构名称等。<br/>
              （4）样机为1台时，填写“样机1”栏，在“样机2”栏填“/”，并在备注中注明大纲规定检验样机为1台。
            </div>
          </el-col>
          <el-col :span="18">
          </el-col>
        </el-row>
        <el-row v-for="(item, index) in reportForm.reportReliabilityResultVo" :key="index">
          <el-col :span="4">
            <el-form-item label="序号">
              {{ index + 1 }}
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item prop="projectName" label="项目">
              <el-input type="text" placeholder="请输入项目" v-model="item.projectName"/>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item prop="unit" label="单位">
              <el-input type="text" placeholder="请输入单位" v-model="item.unit"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="qualifiedIndicator" label="合格指标">
              <el-input type="text" placeholder="请输入合格指标" v-model="item.qualifiedIndicator"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="checkResulto" label="样机1">
              <el-input type="text" placeholder="请输入检查结果（样机1）" v-model="item.checkResulto"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="checkResultt" label="样机2">
              <el-input type="text" placeholder="请输入检查结果（样机2）" v-model="item.checkResultt"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="unitaryDetermine" label="单项判定">
              <el-input type="text" placeholder="请输入单项判定" v-model="item.unitaryDetermine"/>
            </el-form-item>
          </el-col>
          <el-col :offset="20" :span="4">
            <el-form-item>
              <!--              <el-button type="primary" v-if="reportForm.reportReliabilityResultVo.length === index + 1" circle icon="el-icon-plus" @click="addItem(reportForm.reportReliabilityResultVo)"></el-button>-->
              <el-button v-if="index > 0" type="danger" circle icon="el-icon-minus"
                         @click="delItem(reportForm.reportReliabilityResultVo, index)"></el-button>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="1">
            <el-button type="primary" circle icon="el-icon-plus"
                       @click="addItem(reportForm.reportReliabilityConsResultVo)"></el-button>
          </el-col>
          <el-col :span="23">
            <span style="margin-left: 30px; font-weight: bold; font-size: 20px;">
              涵盖机型（或同单元机型）样品可靠性检验结果
            </span>
            <div style="margin-left: 30px">
              <br/>
              （1）单项判定合格填“+”，不合格填“-”。<br/>
              （2）大纲中对样品不适用的检查项目，应在表中列出，在检验结果、单项判定栏中填“/”，并在备注中说明。<br/>
              （3）采信具有资质的检验检测机构出具的报告，不应体现采信项目的数据结果，可在采信项目的“检验结果”“单项判定”栏中划“/”，并在备注中注明采信项目的来源，如：采信报告的编号、名称及检验检测机构名称等。<br/>
              （4）样机为1台时，填写“样机1”栏，在“样机2”栏填“/”，并在备注中注明大纲规定检验样机为1台。
            </div>
          </el-col>
        </el-row>
        <el-row v-for="(item, index) in reportForm.reportReliabilityConsResultVo" :key="index">
          <el-col :span="4">
            <el-form-item label="序号">
              {{ index + 1 }}
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item prop="projectName" label="项目">
              <el-input type="text" placeholder="请输入项目" v-model="item.projectName"/>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item prop="unit" label="单位">
              <el-input type="text" placeholder="请输入单位" v-model="item.unit"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="qualifiedIndicator" label="合格指标">
              <el-input type="text" placeholder="请输入合格指标" v-model="item.qualifiedIndicator"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="checkResulto" label="样机1">
              <el-input type="text" placeholder="请输入检查结果（样机1）" v-model="item.checkResulto"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="checkResultt" label="样机2">
              <el-input type="text" placeholder="请输入检查结果（样机2）" v-model="item.checkResultt"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="unitaryDetermine" label="单项判定">
              <el-input type="text" placeholder="请输入单项判定" v-model="item.unitaryDetermine"/>
            </el-form-item>
          </el-col>
          <el-col :offset="20" :span="4">
            <el-form-item>
              <!--              <el-button type="primary" v-if="reportForm.reportReliabilityConsResultVo.length === index + 1" circle icon="el-icon-plus" @click="addItem(reportForm.reportReliabilityConsResultVo)"></el-button>-->
              <el-button v-if="index > 0" type="danger" circle icon="el-icon-minus"
                         @click="delItem(reportForm.reportReliabilityConsResultVo, index)"></el-button>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="8">
            <el-form-item prop="reportWriter" label="报告编写人">
<!--              <el-input type="text" placeholder="请输入报告编写人" v-model="reportForm.reportWriter"/>-->
              <electronic-signatures :value="reportForm.reportWriter" @change="reportWriteChange($event, reportForm, 'reportWriter')"></electronic-signatures>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="reportWriter" label="报告编写日期">
              <el-date-picker
                  v-model="reportForm.reportDate"
                  type="date"
                  format="yyyy-MM-dd"
                  placeholder="选择报告编写日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-form-item>
          <el-button type="primary" @click="reportSubmit">保存</el-button>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="reportDialogShow = false">关闭</el-button>
      </span>
    </el-dialog>
    <el-dialog
        :title="productInfoForm.id ? '修改' : '添加'"
        :visible.sync="productInfoDialogShow"
        width="600px"
        fullscreen
        @close="dialogClose"
    >
      <el-form ref="form" :model="productInfoForm" label-width="100px" :rules="rules">
        <el-row>
          <el-col :span="8">
            <el-form-item prop="productName" label="样品名称">
              <el-input type="text" placeholder="请输入样品名称" v-model="productInfoForm.productName"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="model" label="样品型号">
              <el-input type="text" placeholder="请输入样品型号" v-model="productInfoForm.model"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="sampleNum" label="涵盖机型">
              <el-input type="text" placeholder="请输入涵盖机型（或同单元机型）" v-model="productInfoForm.coveredModels"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="manufacturer" label="生产者">
              <el-input type="text" placeholder="请输入生产者" v-model="productInfoForm.manufacturer"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="manufacturerAddress" label="注册地址">
              <el-input type="text" placeholder="请输入注册地址" v-model="productInfoForm.manufacturerAddress"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="manufacturerPhone" label="电话">
              <el-input type="text" placeholder="请输入电话" v-model="productInfoForm.manufacturerPhone"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="manufacturerFax" label="传真">
              <el-input type="text" placeholder="请输入传真" v-model="productInfoForm.manufacturerFax"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="manufacturerContact" label="联系人">
              <el-input type="text" placeholder="请输入联系人" v-model="productInfoForm.manufacturerContact"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="manufacturerZipcode" label="邮政编码">
              <el-input type="text" placeholder="请输入邮政编码" v-model="productInfoForm.manufacturerZipcode"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="factory" label="生产厂">
              <el-input type="text" placeholder="请输入生产厂" v-model="productInfoForm.factory"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="factoryAddress" label="注册地址">
              <el-input type="text" placeholder="请输入注册地址" v-model="productInfoForm.factoryAddress"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="factoryPhone" label="电话">
              <el-input type="text" placeholder="请输入电话" v-model="productInfoForm.factoryPhone"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="factoryFax" label="传真">
              <el-input type="text" placeholder="请输入传真" v-model="productInfoForm.factoryFax"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="factoryContact" label="联系人">
              <el-input type="text" placeholder="请输入联系人" v-model="productInfoForm.factoryContact"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="factoryZipcode" label="邮政编码">
              <el-input type="text" placeholder="请输入邮政编码" v-model="productInfoForm.factoryZipcode"/>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item prop="judgmentBasis" label="鉴定依据">
              <el-input type="text" placeholder="请输入鉴定依据" v-model="productInfoForm.judgmentBasis"/>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item prop="judgmentConclusion" label="鉴定结论">
              <div style="border: 1px solid #ccc; max-height: 300px;">
                <toolbar
                    style="border-bottom: 1px solid #ccc"
                    :editor="editor"
                    :defaultConfig="toolbarConfig"
                    mode="default"
                />
                <editor
                    style="height: 800px; overflow-y: hidden;"
                    v-model="productInfoForm.judgmentConclusion"
                    :defaultConfig="editorConfig"
                    mode="default"
                    @onCreated="onCreated"
                />
              </div>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item prop="registeredAddressSample" label="备注">
              <el-input type="textarea" placeholder="请输入备注" v-model="productInfoForm.remark"/>
            </el-form-item>
          </el-col>
        </el-row>
        <br/>
        <el-row>
          <el-col :span="8">
            <el-form-item prop="pictureProductName" label="产品照片">
              <el-upload
                  class="avatar-uploader"
                  :style="{border: !productInfoForm.pictureProductName ? '1px solid #d9d9d9' : ''}"
                  style="max-width: 160px; max-height: 160px"
                  :action="baseUrl + '/reportApproval/report/fileUplod'"
                  :headers="{'Authorization': getToken()}"
                  :show-file-list="false"
                  :on-success="(response, file, fileList) => {
                    return handleAvatarSuccess(response, file, fileList, productInfoForm, 'pictureProductName')
                  }"
                  :before-upload="beforeAvatarUpload">
                <img v-if="productInfoForm.pictureProductName" :src="productInfoForm.pictureProductName"
                     style="height: 160px; max-width: 260px;" class="avatar">
                <i v-else class="el-icon-plus avatar-uploader-icon" style="margin-left: 40px; margin-top: 40px;"></i>
              </el-upload>
              <!--              <el-input type="text" placeholder="请输入样品照片" v-model="productInfoForm.pictureProductName"/>-->
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="pictureModel" label="产品特征">
              <el-upload
                  class="avatar-uploader"
                  :style="{border: !productInfoForm.pictureModel ? '1px solid #d9d9d9' : ''}"
                  style="max-width: 160px; max-height: 160px"
                  :action="baseUrl + '/reportApproval/report/fileUplod'"
                  :headers="{'Authorization': getToken()}"
                  :show-file-list="false"
                  :on-success="(response, file, fileList) => {
                    return handleAvatarSuccess(response, file, fileList, productInfoForm, 'pictureModel')
                  }"
                  :before-upload="beforeAvatarUpload">
                <img v-if="productInfoForm.pictureModel" :src="productInfoForm.pictureModel"
                     style="height: 160px; max-width: 260px;" class="avatar">
                <i v-else class="el-icon-plus avatar-uploader-icon" style="margin-left: 40px; margin-top: 40px;"></i>
              </el-upload>
              <!--              <el-input type="text" placeholder="请输入产品特征" v-model="productInfoForm.pictureModel"/>-->
            </el-form-item>
          </el-col>
        </el-row>
        <br/>
        <el-row>
          <el-col :span="1">
            <el-button type="primary" circle icon="el-icon-plus"
                       @click="addItem(productInfoForm.proTecSpecVo)"></el-button>
          </el-col>
          <el-col :span="23">
            <span style="margin-left: 30px; font-weight: bold; font-size: 20px;">
              一致性检查（产品样机技术规格）
            </span>
          </el-col>
        </el-row>
        <el-row v-for="(item, index) in productInfoForm.proTecSpecVo" :key="index">
          <el-col :span="4">
            <el-form-item label="序号">
              {{ index + 1 }}
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item prop="projectName" label="项目">
              <el-input type="text" placeholder="请输入项目" v-model="item.projectName"/>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item prop="unit" label="单位">
              <el-input type="text" placeholder="请输入单位" v-model="item.unit"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="designValue" label="设计值">
              <el-input type="text" placeholder="请输入设计值" v-model="item.designValue"/>
            </el-form-item>
          </el-col>
          <el-col :offset="10" :span="4">
            <el-form-item>
              <!--              <el-button type="primary" v-if="productInfoForm.proTecSpecVo.length === index + 1" circle icon="el-icon-plus" @click="addItem(productInfoForm.proTecSpecVo)"></el-button>-->
              <el-button v-if="index > 0" type="danger" circle icon="el-icon-minus"
                         @click="delItem(productInfoForm.proTecSpecVo, index)"></el-button>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col>
            <el-form-item prop="remarks" label="备注">
              <el-input type="text" placeholder="请输入设计值" v-model="productInfoForm.remarks"/>
            </el-form-item>
          </el-col>
        </el-row>
        <br/>
        <el-row>
          <el-col :span="1">
            <el-button type="primary" circle icon="el-icon-plus"
                       @click="addItem(productInfoForm.proCoveredModelVo, {cover: ['']})"></el-button>
          </el-col>
          <el-col :span="23">
            <span style="margin-left: 30px; font-weight: bold; font-size: 20px;">
              一致性检查（产品样机技术规格）
            </span>
          </el-col>
        </el-row>
        <el-row v-for="(item, index) in productInfoForm.proCoveredModelVo" :key="index">
          <el-col :span="4">
            <el-form-item label="序号">
              {{ index + 1 }}
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item prop="projectName" label="项目">
              <el-input type="text" placeholder="请输入项目" v-model="item.projectName"/>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item prop="unit" label="单位">
              <el-input type="text" placeholder="请输入单位" v-model="item.unit"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="designValue" label="设计值">
              <el-input type="text" placeholder="请输入设计值" v-model="item.designValue"/>
            </el-form-item>
          </el-col>

          <el-col :span="8">
            <el-form-item prop="designValue" label="涵盖值1">
              <el-input type="text" placeholder="请输入涵盖值1" v-model="item.cover1"/>
            </el-form-item>
          </el-col>

          <el-col :span="8">
            <el-form-item prop="designValue" label="涵盖值2">
              <el-input type="text" placeholder="请输入涵盖值2" v-model="item.cover2"/>
            </el-form-item>
          </el-col>

          <el-col :span="8">
            <el-form-item prop="designValue" label="涵盖值3">
              <el-input type="text" placeholder="请输入涵盖值3" v-model="item.cover3"/>
            </el-form-item>
          </el-col>
          <!--          <el-col :span="24">-->
          <!--            <el-form-item label="设计值">-->
          <!--              <el-button type="success" size="mini" circle icon="el-icon-plus" @click="addItem(item.cover, '')"></el-button>-->
          <!--            </el-form-item>-->
          <!--            <el-row>-->
          <!--              <el-col v-for="(c, i) in item.cover" :span="8" :key="i">-->
          <!--                <el-form-item prop="designValue" :label="'涵盖' + (i + 1)">-->
          <!--                  <el-input type="text" :placeholder="'请输入涵盖' + (i + 1)" v-model="item.cover[i]">-->
          <!--                    <el-button type="warning" size="mini" slot="append" icon="el-icon-minus" @click="delItem(item.cover, i)"></el-button>-->
          <!--                  </el-input>-->
          <!--                </el-form-item>-->
          <!--              </el-col>-->
          <!--            </el-row>-->
          <!--          </el-col>-->

          <el-col :offset="10" :span="4">
            <el-form-item>
              <!--              <el-button type="primary" v-if="productInfoForm.proCoveredModelVo.length === index + 1" circle icon="el-icon-plus" @click="addItem(productInfoForm.proCoveredModelVo)"></el-button>-->
              <el-button v-if="index > 0" type="danger" circle icon="el-icon-minus"
                         @click="delItem(productInfoForm.proCoveredModelVo, index)"></el-button>
            </el-form-item>
          </el-col>
        </el-row>
        <br/>

        <el-row>
          <el-col :span="8">
            <el-form-item prop="reportWriter" label="报告编写人">
<!--              <el-input type="text" placeholder="请输入报告编写人" v-model="productInfoForm.reportWriter"/>-->
              <electronic-signatures :value="productInfoForm.reportWriter" @change="reportWriteChange($event, productInfoForm, 'reportWriter')"></electronic-signatures>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item prop="issueDate" label="报告编写日期">
              <el-date-picker
                  v-model="productInfoForm.issueDate"
                  type="date"
                  format="yyyy-MM-dd"
                  placeholder="选择报告编写日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <!--        <el-form-item prop="description" label="备注">-->
        <!--          <el-input type="textarea" placeholder="请输入备注" v-model="productInfoForm.description"/>-->
        <!--        </el-form-item>-->
        <el-form-item>
          <el-button type="primary" @click="productInfoSubmit">保存</el-button>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="productInfoDialogShow = false">关闭</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import {httpBaseUrl} from "@/util/globa";
import '@wangeditor/editor/dist/css/style.css'
import {Editor, Toolbar} from "@wangeditor/editor-for-vue";
import {getToken} from "@/util/auth";
import ElectronicSignatures from "@/components/ElectronicSignatures.vue";

export default {
  name: "Product",
  components: {ElectronicSignatures, Toolbar, Editor},
  data() {
    return {
      baseUrl: httpBaseUrl,
      search: {},
      dialogShow: false,
      reportDialogShow: false,
      productInfoDialogShow: false,
      form: {},
      reportForm: {
        reportConditionVo: [{}],
        reportCheckResultVo: [{}],
        reportSampleSonsResultsVo: [{}],
        reportSampleSafetyResultsVo: [{}],
        reportConsResultsVo: [{}],
        reportSampleSuitResultsVo: [{}],
        reportReliabilityResultVo: [{}],
        reportReliabilityConsResultVo: [{}]
      },
      productInfoForm: {
        proTecSpecVo: [{}],
        proCoveredModelVo: [{}]
      },
      data: [],
      pageNo: 1,
      pageSize: 10,
      total: 0,
      rules: {},
      editor: null,
      toolbarConfig: {},
      editorConfig: {
        placeholder: '请输入内容...'
      },
      lineWidth: 6,
      lineColor: '#000000',
      bgColor: '',
      resultImg: '',
      isCrop: false
    }
  },
  mounted() {
    this.getData();
  },
  methods: {
    reportWriteChange(value, form, item) {
      form[item] = value;
      console.log(form);
    },
    handleReset() {
      this.$refs.esign.reset();
      this.resultImg = ''
    },
    //生成签名图片..
    handleGenerate(form) {
      this.$refs.esign.generate().then(res => {
        let randnum = Math.random() * 10000000000000
        randnum = Math.floor(randnum)
        let fileName = "esign/" + randnum + '.png'
        let file = this.dataURLtoFile(res, fileName);
        // /reportApproval/report/fileUplod
        const formData = new FormData();
        formData.append('file', file); // 将文件添加到 FormData 对象
        this.$http.post('/reportApproval/report/fileUplod', formData, {
          headers: {'Content-Type': 'multipart/form-data'}
        }).then(res => {
          form.reportWriter = res.data;
        })
      }).catch(err => {
        console.log(err);
        this.$message.error('请签名之后提交！')
      })
    },
    dataURLtoFile(dataurl, filename) {
      let arr = dataurl.split(','), mime = arr[0].match(/:(.*?);/)[1],
          bstr = atob(arr[1]), n = bstr.length, u8arr = new Uint8Array(n);
      while (n--) {
        u8arr[n] = bstr.charCodeAt(n);
      }
      return new File([u8arr], filename, {type: mime});
    },
    onCreated(editor) {
      this.editor = Object.seal(editor) // 一定要用 Object.seal() ，否则会报错
      const uploadImage = this.editor.getMenuConfig('uploadImage')
      uploadImage.server = '/upload/image'
      uploadImage.fieldName = 'file'
      uploadImage.headers = {
        token: getToken()
      }
      uploadImage.maxFileSize = 10 * 1024 * 1024
      const uploadVideo = this.editor.getMenuConfig('uploadVideo')
      uploadVideo.server = '/upload/video'
      uploadVideo.fieldName = 'file'
      uploadVideo.headers = {
        token: getToken()
      }
      uploadVideo.maxFileSize = 500 * 1024 * 1024
    },
    handleAvatarSuccess(res, file, fileList, form, item) {
      // this.imageUrl = URL.createObjectURL(file.raw);
      form[item] = res.data;
    },
    beforeAvatarUpload(file) {
      const isImage = file.type.concat('image');
      if (!isImage) {
        this.$message.error('上传文件只能是图片!');
      }
      return isImage;
    },
    getToken() {
      return `Bearer ${sessionStorage.getItem('token')}`;
    },
    getData() {
      this.search.page = this.pageNo;
      this.search.limit = this.pageSize;
      this.$http.post(`/reportApproval/product/list`, this.search).then(res => {
        if (res.code === 0) {
          this.pageSize = res.page.pageSize
          this.pageNo = res.page.currPage
          this.total = res.page.totalCount
          this.data = res.page.list
        }
      })
    },
    sizeChange(val) {
      this.pageNo = 1;
      this.pageSize = val;
      this.getData();
    },
    currentChange(val) {
      this.pageNo = val;
      this.getData();
    },
    searchClick() {
      this.pageNo = 1;
      this.getData()
    },
    dialogClose() {
      this.form = {};
      this.resetReportForm();
      this.resetProductInfoForm();
      this.$refs['form'].clearValidate()
    },
    resetProductInfoForm() {
      this.productInfoForm = {
        proTecSpecVo: [{}],
        proCoveredModelVo: [{}]
      }
    },
    resetReportForm() {
      this.reportForm = {
        reportConditionVo: [{}],
        reportCheckResultVo: [{}],
        reportSampleSonsResultsVo: [{}],
        reportSampleSafetyResultsVo: [{}],
        reportConsResultsVo: [{}],
        reportSampleSuitResultsVo: [{}],
        reportReliabilityResultVo: [{}],
        reportReliabilityConsResultVo: [{}]
      }
    },
    editReportForm(id) {
      this.$http.post(`/reportApproval/product/info/getreport/${id}`).then(res => {
        if (res.code === 0) {
          if (res.product) {
            this.reportForm = res.product;
            if (!this.reportForm.reportConsResultsVo) this.reportForm.reportConsResultsVo = [];
            if (!this.reportForm.reportSampleSuitResultsVo) this.reportForm.reportSampleSuitResultsVo = [];
          } else this.resetReportForm();
        }
      })
    },
    editProductInfoForm(id) {
      this.$http.post(`/reportApproval/productinfo/info/${id}`).then(res => {
        if (res.code === 0) {
          if (res.productInfo) {
            this.productInfoForm = res.productInfo;
            if (!this.productInfoForm.proTecSpecVo) this.productInfoForm.proTecSpecVo = [{}];
            if (!this.productInfoForm.proCoveredModelVo) this.productInfoForm.proCoveredModelVo = [{}];
          } else this.resetReportForm();
        }
      })
    },
    reportSubmit() {
      this.reportForm.productId = this.form.prId;
      if (this.reportForm.id) {
        this.$http.post(`/reportApproval/report/update`, this.reportForm).then(res => {
          if (res.code === 0) {
            this.$Message.success(res.msg)
            this.getData()
            this.reportDialogShow = false
          }
        })
      } else {
        this.$http.post(`/reportApproval/report/save`, this.reportForm).then(res => {
          if (res.code === 0) {
            this.$Message.success(res.msg)
            this.getData()
            this.dialogShow = false
          }
        })
      }
    },
    productInfoSubmit() {
      this.productInfoForm.productId = this.form.prId;
      if (this.productInfoForm.id) {
        this.$http.post(`/reportApproval/productinfo/update`, this.productInfoForm).then(res => {
          if (res.code === 0) {
            this.$Message.success(res.msg)
            this.getData()
            this.productInfoDialogShow = false
          }
        })
      } else {
        this.$http.post(`/reportApproval/productinfo/save`, this.productInfoForm).then(res => {
          if (res.code === 0) {
            this.$Message.success(res.msg)
            this.getData()
            this.productInfoDialogShow = false
          }
        })
      }
    },
    submit() {
      this.$refs['form'].validate((valid) => {
        if (valid) {
          if (this.form.prId) {
            this.form.adUpdated = null;
            this.form.adCreated = null;
            this.$http.post(`/reportApproval/product/update`, this.form).then(res => {
              if (res.code === 0) {
                this.$Message.success(res.msg)
                this.getData()
                this.dialogShow = false
              }
            })
          } else {
            this.$http.post(`/reportApproval/product/save`, this.form).then(res => {
              if (res.code === 0) {
                this.$Message.success(res.msg)
                this.getData()
                this.dialogShow = false
              }
            })
          }
        }
      });
    },
    addItem(array, value = {}) {
      array.push(value);
    },
    delItem(array, index) {
      array.splice(index, 1);
    },
    del(id) {
      this.$confirm('是否确认删除?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        console.log(id)
        this.$http.post(`/reportApproval/product/delete`, [id]).then(res => {
          if (res.code === 0) {
            this.getData()
            this.$Message.success(res.msg)
          }
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        });
      });
    }
  }
}
</script>

<style scoped>

</style>
